/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.manage.repository.mapper;

import info.peigen.hotpot.business.account.core.repository.entity.AccountTransLogEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlManageMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

/**
 * <b>(AccountTransLogManageMapper)</b>
 * 管理后台 "账户交易流水记录" 数据库映射服务
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-08-30
 */
@SuppressWarnings("unused")
public interface AccountTransLogManageMapper extends AbstractBeetlSqlManageMapper<AccountTransLogEntity> {

    // 唯一索引[trans_log_id]
    @Sql("select * from account_trans_log where trans_log_id = ?")
    @Select
    AccountTransLogEntity findByTransLogId(String transLogId);

    @Sql("select * from account_trans_log where trans_log_id = ? for update")
    @Select
    AccountTransLogEntity lockByTransLogId(String transLogId);

    @Sql("delete from account_trans_log where trans_log_id = ?")
    @Update
    void deleteByTransLogId(String transLogId);

    // 索引[trade_id]
    @Sql("select * from account_trans_log where trade_id = ?")
    @Select
    AccountTransLogEntity findByTradeId(String tradeId);

    @Sql("delete from account_trans_log where trade_id = ?")
    @Update
    void deleteByTradeId(String tradeId);

    // 索引[trans_code]
    @Sql("select * from account_trans_log where trans_code = ?")
    @Select
    AccountTransLogEntity findByTransCode(String transCode);

    @Sql("delete from account_trans_log where trans_code = ?")
    @Update
    void deleteByTransCode(String transCode);

    // 索引[debit_account_id]
    @Sql("select * from account_trans_log where debit_account_id = ?")
    @Select
    AccountTransLogEntity findByDebitAccountId(String debitAccountId);

    @Sql("delete from account_trans_log where debit_account_id = ?")
    @Update
    void deleteByDebitAccountId(String debitAccountId);

    // 索引[credit_account_id]
    @Sql("select * from account_trans_log where credit_account_id = ?")
    @Select
    AccountTransLogEntity findByCreditAccountId(String creditAccountId);

    @Sql("delete from account_trans_log where credit_account_id = ?")
    @Update
    void deleteByCreditAccountId(String creditAccountId);

    // 索引[trans_time]
    @Sql("select * from account_trans_log where trans_time = ?")
    @Select
    AccountTransLogEntity findByTransTime(String transTime);

    @Sql("delete from account_trans_log where trans_time = ?")
    @Update
    void deleteByTransTime(String transTime);

    // 索引[settle_time]
    @Sql("select * from account_trans_log where settle_time = ?")
    @Select
    AccountTransLogEntity findBySettleTime(String settleTime);

    @Sql("delete from account_trans_log where settle_time = ?")
    @Update
    void deleteBySettleTime(String settleTime);

    // 索引[partner_id]
    @Sql("select * from account_trans_log where partner_id = ?")
    @Select
    AccountTransLogEntity findByPartnerId(String partnerId);

    @Sql("delete from account_trans_log where partner_id = ?")
    @Update
    void deleteByPartnerId(String partnerId);
}